/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.ts.service.impl;

import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xy.lang.domain.Result;
import com.xy.biz.ts.domain.bo.ExaminationPaperQuestionBO;
import com.xy.biz.ts.domain.query.ExaminationPaperQuestionQuery;
import com.xy.biz.ts.service.ExaminationPaperQuestionService;
import com.xy.biz.ts.manager.ExaminationPaperQuestionManager;
import org.springframework.util.CollectionUtils;

/**
 *
 *
 * @author wwj
 * @date 2021-3-23
 */
@Service
public class ExaminationPaperQuestionServiceImpl implements ExaminationPaperQuestionService {

	@Autowired
	private ExaminationPaperQuestionManager examinationPaperQuestionManager;

	@Override
	public Result<?> saveExaminationPaperQuestion(ExaminationPaperQuestionBO examinationPaperQuestionBO) {
		int affectedRows = examinationPaperQuestionManager.saveExaminationPaperQuestion(examinationPaperQuestionBO);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public Result<?> saveAllExaminationPaperQuestion(Collection<ExaminationPaperQuestionBO> collection) {
		if(CollectionUtils.isEmpty(collection)) {
			return Result.success();
		}
		int affectedRows = examinationPaperQuestionManager.saveAllExaminationPaperQuestion(collection);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public Result<?> updateExaminationPaperQuestion(ExaminationPaperQuestionBO examinationPaperQuestionBO) {
		int affectedRows = examinationPaperQuestionManager.updateExaminationPaperQuestion(examinationPaperQuestionBO);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public Result<?> deleteExaminationPaperQuestion(Long examinationPaperQuestionId) {
		int affectedRows = examinationPaperQuestionManager.deleteExaminationPaperQuestion(examinationPaperQuestionId);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public ExaminationPaperQuestionBO getExaminationPaperQuestion(Long examinationPaperQuestionId) {
		return examinationPaperQuestionManager.getExaminationPaperQuestion(examinationPaperQuestionId);
	}

	@Override
	public List<ExaminationPaperQuestionBO> listExaminationPaperQuestionById(Collection<Long> collection) {
		return examinationPaperQuestionManager.listExaminationPaperQuestionById(collection);
	}

	@Override
	public List<ExaminationPaperQuestionBO> listExaminationPaperQuestion(ExaminationPaperQuestionQuery query) {
		return examinationPaperQuestionManager.listExaminationPaperQuestion(query);
	}

	@Override
	public int countExaminationPaperQuestion(ExaminationPaperQuestionQuery query) {
		return examinationPaperQuestionManager.countExaminationPaperQuestion(query);
	}

}
